//
//  StoreCell.m
//  KTVShopProduct
//
//  Created by paeanSs on 2017/11/8.
//  Copyright © 2017年 paeanSs. All rights reserved.
//

#import "StoreCell.h"


#define IMG_HEIGHT 205.0/750.0 * KTScreenWidth
#define IMG_WIDTH  IMG_HEIGHT/205.0 * 315.0

@implementation StoreCell
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupSubViews];
    }
    return self;
}

- (void)setupSubViews{
    self.layer.borderColor = UIColorFromHex(0xebebeb).CGColor;
    self.layer.borderWidth = 0.5;
    
    CGFloat logoTop = 16/667.0 * KTScreenHeight;
    
    UIImage *logoImage = [UIImage imageNamed:@""];
    
    self.storeLogoView = [[UIImageView alloc] initWithImage:logoImage];
    [self.contentView addSubview:self.storeLogoView];
    
    [self.storeLogoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(IMG_WIDTH, IMG_HEIGHT));
        make.top.equalTo(self).offset(logoTop);
        make.centerX.equalTo(self);
    }];
    
    CGFloat titleTop = 8/667.0 * KTScreenHeight;
    
    self.titleLbl = [[UILabel alloc] init];
    self.titleLbl.textColor = UIColorFromHex(0x232323);
    self.titleLbl.textAlignment = NSTextAlignmentLeft;
    self.titleLbl.font = [UIFont systemFontOfSize:13];
    [self.titleLbl sizeToFit];
    [self.contentView addSubview:self.titleLbl];
    
    [self.titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(self.titleLbl);
        make.centerX.width.equalTo(self.storeLogoView);
        make.top.equalTo(self.storeLogoView.mas_bottom).offset(titleTop);
    }];
    CGFloat addressTop = 6/667.0 * KTScreenHeight;

    self.addressLbl = [[UILabel alloc] init];
    self.addressLbl.textColor = NormalDefalutColor;
    self.addressLbl.textAlignment = NSTextAlignmentLeft;
    [self.addressLbl sizeToFit];
    self.addressLbl.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.addressLbl];
    
    [self.addressLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.equalTo(self.addressLbl);
        make.centerX.width.equalTo(self.storeLogoView);
        make.top.equalTo(self.titleLbl.mas_bottom).offset(addressTop);
    }];
    
}

- (void)confiModel:(StoreModel *)model{
    self.storeLogoView.image = [UIImage imageNamed:model.url_image];
    self.titleLbl.text = model.title;
    self.addressLbl.text = model.address;
    self.titleLbl.numberOfLines = 1;
}
- (void)configRecommendModel:(StoreModel *)model{
    self.storeLogoView.image = [UIImage imageNamed:model.url_image];
    self.titleLbl.text = model.title;
    self.addressLbl.text = @"";
    self.titleLbl.numberOfLines = 0;
}

@end
